// component/order-details/order-details.js
const { API_SNZO_FILE_URL } = require("../../utils/wxapi");
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    orderInfo: {
      type: Object,
      value: null
    },
    show: {
      type: Boolean,
      value: false
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    snzoImgUrl: API_SNZO_FILE_URL
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 预览艺术品
     * @param {*} e 
     */
    previewImage(e) {
      const worksItem = e.currentTarget.dataset.worksItem;
      wx.previewMedia({
        sources: [
          {
            url: this.data.snzoImgUrl + (worksItem.worksPhotoUrl || worksItem.standby1)
          }
        ],
      })
    },

    /**
     * 同意/不同意议价 5-同意 6-同意
     */
    bargainWorks(e) {
      const bargainType = e.currentTarget.dataset.bargainType;
      this.triggerEvent('bargainWorks', { worksInfo: this.data.orderInfo, bargainType });
    },

    /**
    * 下载艺术品
    * @param {*} e 
    */
    downloadWorks(e) {
      this.triggerEvent('downloadWorks', { worksInfo: this.data.orderInfo });
    },

    /**
     * 取消弹窗
     */
    cancelPopup() {
      this.triggerEvent('cancelPopup');
    },
  }
})